<meta charset='utf-8'>	
<script type="text/javascript" src="/public/admin/js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="/public/admin/js/admin.js"></script>
<script type="text/javascript" language="javascript" src="/public/datetimepicker/jquery.datetimepicker.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function(){
	$(".row").hover(function(){
		$(this).css("background","#f7f7f7");
	});
	$(".row").mouseleave(function(){
		$(this).css("background","white");
	});
	// $("#cancel").click(function(){
	// 	window.location('/admin/settingAccount');
	// });
	$("#fullname").blur(function(){
		var fullname=$("#fullname").val();
		if($.trim(fullname)==''){
			$("#err").html("Họ và tên không được bỏ trống");
			$("#change_name").attr("disabled",true);
		 }else{
			$("#err").html('');
			document.getElementById("change_name").disabled = false;
		}
	});
	$("input[name=cancel]").click(function(){
		window.location.assign("/admin/settingAccount");
	});

});
function show(e){
	switch(e){
		case 'name':
			$('#name').closest(".row").after($("#edit_name"));
			$("#edit_birthday,#edit_address,#edit_phone,#edit_mail").hide();
			$("#edit_name").show();
			break;
		case 'date':
			$('#birthday').closest(".row").after($("#edit_birthday"));
			$("#edit_name,#edit_address,#edit_phone,#edit_mail").hide();
			$("#edit_birthday").show();
			break;
		case 'address':
			$('#address').closest(".row").after($("#edit_address"));
			$("#edit_birthday,#edit_name,#edit_phone,#edit_mail").hide();
			$("#edit_address").show();
			break;
		case 'phone':
			$('#phone').closest(".row").after($("#edit_phone"));
			$("#edit_birthday,#edit_address,#edit_name,#edit_mail").hide();
			$("#edit_phone").show();
			break;
		case 'email':
			$("#mail").closest(".row").after($("#edit_mail"));
			$("#edit_birthday,#edit_address,#edit_phone,#edit_name").hide();
			$("#edit_mail").show();
			break;
	}
	
	
}
function change(e){
		switch(e){
			case 'name':
					var data = $("#fullname").val();
					break;
			case 'birthday':
					var data = $("#birthday_").val();
					break;
			case 'address':
					var data = $("#address_").val();
					break;
			case 'email':
					var data = $("#email_").val();
					break;
			case 'phone':
					var data = $("#phone_").val();
					break;
		}
		var username = "<?php echo $user_info['username'];?>";
		$.get("/admin/edit_account?username="+username+"&select="+e+'&data='+data).success(function(data){
				window.location=('/admin/settingAccount');
		});
}
</script>
<style type="text/css">
	#account{
	}
	.breadcrumb{
		padding-top:20px;
	}
	.breadcrumb img{
		height: 30px;
		float: left;
	}
	.breadcrumb span{
		margin-left: 10px;
		font-size: 24px;

	}
	.cot1{
		width: 200px;
		float: left;
	}
	.cot2{
		width: 500px;
		float: left;
		font-family: cursive;
		color: #686363;
	}
	.cot3{
		float: left;
		width: 	100px;
	}
	.cot3:hover{
		cursor: pointer;
		text-decoration: underline;
		color: blue;
		background: url('/public/admin/img/edit.ico') no-repeat top right;
	}
	.account_content{
		width: 800px;
		margin: 30px 78px;
	}
	.row{
		height: 25px;
		border-bottom: 1px solid #ccc;
		padding-top: 15px;
	}
	#account #edit{
		display: none;
	}
	#edit_name,#edit_birthday,#edit_phone,#edit_mail,#edit_address {
		min-height: 75px;
		background: #f2f2f2;
		padding: 15px 0px 0px 170px;
	}
	#account input[type=text]{
		border-radius: 5px;
		border: 1px solid #ccc;
		height: 23px;
		width: 200px;
		padding:0px 5px;
	}
	#account input[type='submit']{
		background: #579FD0;
		height: 24px;
		border: 1px solid #ccc;
		width: 100px;
		color: white;
		margin: 20px 24px 19px 35px;
	}
	#account input[type='submit']:hover{
		cursor: pointer;
		background: #55809D;
	}
	#err{
		color: red;
		font-family: initial;
		margin-top: 10px;
		margin-left: 70px;
	}
</style>
<div id="account">
	<div class="breadcrumb">
		<img src="/public/admin/img/setting.ico" alt=""><span>Thiết lập tài khoản</span>
	</div>
		<div class="account_content">
			<div class="row">
				<div class="cot1">Họ và Tên</div>
				<div class="cot2">
					<?php  
						if($user_info['fullname']){
							echo $user_info['fullname'];
						}else{
							echo "";
						}
					?>
				</div>
				<div class="cot3" id="name" onclick="show('name');" > Chỉnh sửa</div>
			</div>
			<div class="row">
				<div class="cot1">Ngày sinh</div>
				<div class="cot2">
					<?php  
						if($user_info['birthday']){
							echo inttodate($user_info['birthday']);
						}else{
							echo " &nbsp";
						}
					?>
				</div>
				<div class="cot3" id="birthday" onclick="show('date');">Chỉnh sửa</div>
			</div>
			<div class="row">
				<div class="cot1">Địa chỉ</div>
				<div class="cot2">
					<?php  
						if($user_info['address']){
							echo $user_info['address'];
						}else{
							echo "&nbsp";
						}
					?>
				</div>
				<div class="cot3" id="address" onclick="show('address');">Chỉnh sửa</div>
			</div>
			<div class="row">
				<div class="cot1">Điện thoại</div>
				<div class="cot2">
					<?php  
						if($user_info['phone']){
							echo $user_info['phone'];
						}else{
							echo "&nbsp";
						}
					?>		
				</div>
				<div class="cot3" id="phone" onclick="show('phone');">Chỉnh sửa</div>
			</div>
			<div class="row">
				<div class="cot1">Email</div>
				<div class="cot2">
					<?php  
						if($user_info['email']){
							echo $user_info['email'];
						}else{
							echo "&nbsp";
						}
					?>
				</div>
				<div class="cot3" id="mail" onclick="show('email');">Chỉnh sửa</div>
			</div>
		</div>
	<div id="edit">
		<div  id="edit_name">
			Tên thay thế <input type="text" class="" id="fullname" value="<?php echo $user_info['fullname'];?>"><br />
			<div id="err"></div>
			<input type="submit" onclick="change('name');" value="Thay đổi" id="change_name"><input type="submit" value="Hủy bỏ" name="cancel" >
			
		</div>
		<div id="edit_birthday">
			Ngày sinh thay thế <input type="text" class="datetimepicker" id="birthday_" value="<?php  echo isset($user_info['birthday'])? inttodate($user_info['birthday']):inttodate(time());?>"><br />
			<input type="submit" onclick="change('birthday');" value="Thay đổi"><input type="submit" value="Hủy bỏ" name="cancel" >
		</div>
		<div id="edit_address">
			Địa chỉ thay thế <input type="text" id="address_" value="<?php echo $user_info['address'];?>"><br />
			<input type="submit" onclick="change('address');" value="Thay đổi"><input type="submit" name="cancel" >
		</div>
		<div id="edit_phone">
			Điện thoại thay thế <input type="text" id="phone_" value="<?php echo $user_info['phone'];?>"><br />
			<input type="submit" onclick="change('phone');" value="Thay đổi"><input type="submit" value="Hủy bỏ" name="cancel" >
		</div>
		<div id="edit_mail">
			Địa chỉ mail thay thế <input type="text" id="email_" value="<?php echo $user_info['email'];?>"><br />
			<input type="submit" onclick="change('email');" value="Thay đổi"><input type="submit" value="Hủy bỏ" name="cancel" >
		</div>
	</div>
</div>